#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;


int a[7], ans;
int main()
{
    int ncase, i, k;
    //scanf("%d", &ncase);
    ncase = 1000000000;
    while (ncase-->0) {
        for (i=1; i<=6; ++i)
            scanf("%d", a+i);
        if (a[0]==0 && a[1]==0 && a[2]==0 && a[3]==0 && a[4]==0 && a[5]==0 && a[6]==0)
            break; 
        ans = a[6];
        ans += a[5];
        a[1] -= a[5]*11;
        ans += a[4];
        a[2] -= a[4]*5;
        // put 3x3
        ans += a[3]/4;
        a[3] %= 4;
        if (a[3] != 0) 
            ans ++;
        
        if (a[3] == 1) {
            a[2] -= 5;
            a[1] -= 7;
        } else if (a[3] == 2) {
            a[2] -= 3;
            a[1] -= 6;
        } else if (a[3] == 3) {
            a[2] -= 1;
            a[1] -= 5;
        }   
        // put 2x2    
        if (a[2] <= 0) {
            a[1] -= -a[2] * 4;
        } else {
            ans += a[2]/9;
            a[2] %= 9;
            if (a[2]) {
                ans ++;
                a[1] -= 36 - a[2]*4;
            }    
        }     
        // put 1x1
        if (a[1] > 0) {
            ans += a[1]/36;
            a[1] %= 36;
            if (a[1]) ans++;
        }    
        printf("%d\n", ans);
    }    
    return 0;
}    
